﻿@page "/BlazorDownloadFileTest"

<h1>Download File From Text</h1>

<Button Text="download" OnClick="DownLoadClick" />

@code {
    [Inject]
    public IBlazorDownloadFileService BlazorDownloadFileService { get; set; }

    string json = @"{
TestData: [
    {
        Name: ""Customer 1"",
        StreetAddress: ""Sölfang""
    },
    {
        Name: ""Customer 2"",
        StreetAddress: ""Skärholmen""
    },
    {
        Name: ""Customer 3"",
        StreetAddress: ""Trömso""
    },
    {
        Name: ""Customer 4"",
        StreetAddress: ""Fårsta Strand""
    },
    {
        Name: ""Customer 5"",
        StreetAddress: ""Gullmarsplan""
    },
    {
        Name: ""Customer 6"",
        StreetAddress: ""Råcksta""
    },
    {
        Name: ""Customer 7"",
        StreetAddress: ""Vällingby""
    }
]
}";

    public async Task DownLoadClick()
    {
        await BlazorDownloadFileService.DownloadFileFromText("test.json", json, System.Text.Encoding.UTF8, "application/octet-stream");
    }

}
